//
//  PhotoCell.m
//  晓礼
//
//  Created by Angel on 15/11/10.
//  Copyright © 2015年 qianfeng. All rights reserved.
//

#import "PhotoCell.h"
#import "PhotoView.h"


@interface PhotoCell()

@property (weak, nonatomic) IBOutlet UILabel *dayLabel;
@property (weak, nonatomic) IBOutlet UILabel *yearmonthLabel;
@property (weak, nonatomic) IBOutlet PhotoView *photoView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *photoViewWidthConstant;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *photoViewHeightConstant;

@end

@implementation PhotoCell

- (void)awakeFromNib {
    // Initialization code
}
- (void)setModel:(XiangceModel *)model
{
    _model = model;
    NSLog(@"%@",_model.datettime);
    
    NSMutableArray * mrr = [self seperateDate:_model.datettime];
    //时间显示
    self.dayLabel.text = [mrr lastObject];
   
    self.yearmonthLabel.text = [NSString stringWithFormat:@"%@%@",@"2015年",[mrr firstObject]];
    //图片显示
    
    _photoView.imagearray = _model.imgurl;
    float wdith = _photoViewWidthConstant.constant;
    [self.photoView setImageArray:model.imgurl withInWidth:wdith];
    float imageViewHeight = [PhotoView heightOfContent:model.imgurl withInWidth:wdith];
    self.photoViewHeightConstant.constant = imageViewHeight;
}
- (NSMutableArray *)seperateDate:(NSString *)str
{
    NSString * str1 = [str componentsSeparatedByString:@" "][0];
    NSMutableArray * arr = [NSMutableArray array];
    [arr addObject:[str1 substringToIndex:3]];
    [arr addObject:[str1 substringWithRange:NSMakeRange(3, 3)]];
    
    return arr;
}

- (IBAction)moreBtn:(id)sender {
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
